<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<body>

<form id="informationForm" role="form" method="post" action="onlineRepairControl/update">
    <input type="hidden" name="id" id="informationId" th:value="${entity.id}"/>
    <div class="form-group">
        <label for="repairName">报修人姓名:</label>
        <input type="text" class="form-control" name="repairName" id="repairName" readonly="readonly" th:value="${entity.repairName}"/>
    </div>
    <div class="form-group">
        <label for="repairTel">联系电话:</label>
        <input type="number" class="form-control" name="repairTel" id="repairTel" readonly="readonly" th:value="${entity.repairTel}" />
    </div>
    <div class="form-group">
        <label for="title">报修标题:</label>
        <input type="text" class="form-control" name="title" id="title" readonly="readonly" th:value="${entity.title}"/>
    </div>
    <div class="form-group">
        <label for="repairTypeName">报修项目名称:</label>
        <input type="text" class="form-control" name="repairTypeName" id="repairTypeName" readonly="readonly" th:value="${entity.repairTypeName}"/>
    </div>
    <div class="form-group">
        <label for="descInf">备注:</label>
        <input type="text" class="form-control" name="descInf" id="descInf" readonly="readonly" th:value="${entity.descInf}"/>
    </div>
    <div class="form-group">
        <label for="repairType">报修类型:</label>
        <input type="text" class="form-control" name="repairType" id="repairType" readonly="readonly" th:value="${entity.repairType}"/>
    </div>
    <div class="form-group">
        <label for="fixName">维修人员:</label>
        <input type="text" class="form-control" name="fixName" id="fixName" th:value="${entity.fixName}"/>
    </div>
    <div class="form-group">
        <label for="fixTel">维修人员电话:</label>
        <input type="tel" class="form-control" name="fixTel" id="fixTel" th:value="${entity.fixTel}"/>
    </div>
    <div class="form-group">
        <label for="fixState">维修状态:</label>
        <select class="form-control" name="fixState" id="fixState">

        </select>
    </div>
    <div class="form-group">
        <label for="refuseReason">拒绝原因:</label>
        <input type="text" class="form-control" name="refuseReason" id="refuseReason" th:value="${entity.refuseReason}"/>
    </div>
</form>
<script th:inline="javascript">
    <![CDATA[
    $(function () {
        $.post("dict/getType", {type: "REPAIR_STATE"},
            function (r) {
                var repairType = [[${entity.fixState}]];
                for (var i = 0; i < r.data.length; i++) {
                    if (r.data[i].value == repairType) {
                        $("#fixState", window.top.document).append("<option selected=true  value=" + r.data[i].value + ">" + r.data[i].text + "</option>");
                    } else {
                        $("#fixState", window.top.document).append("<option value=" + r.data[i].value + ">" + r.data[i].text + "</option>");
                    }
                }
            });
        $('#informationForm', window.top.document).bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                fixName: {
                    validators: {
                        notEmpty: {
                            message: '维修人不能为空'
                        }
                    }
                },

                fixTel: {
                    validators: {
                        notEmpty: {
                            message: '联系电话不能为空'
                        }
                    }
                },
                fixState: {
                    validators: {
                        notEmpty: {
                            message: '维修状态不能为空'
                        }
                    }
                }
            }
        });

        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            $("#btnOk", window.top.document).attr("disabled", true);
            var bootstrapValidator = $("#informationForm", window.top.document).data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                $.post($("#informationForm", window.top.document).attr('action'), $("#informationForm", window.top.document).serialize(), function (e) {
                    if (e.result) {
                        refreshDoQuery();
                        window.Ewin.alert({message: '处理报修成功!'});
                    } else {
                        window.Ewin.alert({message: '处理报修失败!'});
                    }
                    $("#btnOk", window.top.document).attr("disabled", false);
                })
            } else {
                $("#btnOk", window.top.document).attr("disabled", false);
            }
        });

        // 重新刷新当前查询页的数据
        function refreshDoQuery() {
            var iframes = $(window.parent.document).contents().find(".J_iframe");
            for (var i = 0; i < iframes.length; i++) {
                if ($(iframes[i]).css("display") == 'inline') {
                    $('.modal-dialog', window.top.document).parent('div').remove()
                    $('body', window.top.document).find('.modal-backdrop').remove();
                    iframes[i].contentWindow.doQuery();
                    break;
                }
            }
        }
    })
    ]]>
</script>
</body>
</html>